#pragma once
#include "Utilies.h"

namespace vkengine
{
	struct SwapChainSupportDetails {
		VkSurfaceCapabilitiesKHR capabilities{};
		std::vector<VkSurfaceFormatKHR> formats{};
		std::vector<VkPresentModeKHR> presentModes{};
	};

	class Texture;
	class SwapChain
	{
	public:
		void CreateSwapChain(VkPhysicalDevice phsyicalDevice, VkDevice device, VkSurfaceKHR surface, GLFWwindow* window);
		void CreateImageViews(VkDevice device, Texture* texture);

		VkSurfaceFormatKHR ChooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
		VkPresentModeKHR ChooseSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes);
		VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, GLFWwindow* window);
		SwapChainSupportDetails QuerySwapChainSupport(VkPhysicalDevice device, VkSurfaceKHR surface);

		void Cleanup(VkDevice device);

		VkSwapchainKHR GetSwapChain() { return m_SwapChain; }
		VkFormat GetSwapChainImageFormat() { return m_SwapChainImageFormat; }
		VkExtent2D GetSwapChainExtent() { return m_SwapChainExtent; }
		std::vector<VkImageView> GetSwapChainImageViews(){ return m_SwapChainImageViews; }

	private:
		VkSwapchainKHR m_SwapChain=VK_NULL_HANDLE;
		std::vector<VkImage> m_SwapChainImages;
		VkFormat m_SwapChainImageFormat{};
		VkExtent2D m_SwapChainExtent{};
		std::vector<VkImageView> m_SwapChainImageViews;
	};
}


